<script setup lang="ts">

import Login from '@/components/login/index.vue'
import Updater from '@/components/updater/index.vue'
import Layout from '@/layout/index.vue'
import { ref } from 'vue'
import { useUserStore } from './stores/user'
import { useCookieStore } from './stores/cookie'
import { Cookie } from 'electron'
const userStore = useUserStore()
const cookieStore = useCookieStore()
const needUpdate = ref(false)

const globalVal = globalThis as any
// 登录
globalVal.login = () => {
  userStore.login()
}

/**
 * 监听Cookie
 */
globalVal.electronApi.onCookieChanged( (cookie:Cookie) => {
  if(cookie.domain == 'syt.kwaixiaodian.com'){
    cookieStore.push(cookie);
  }
})



</script>

<template>
  <Updater v-model="needUpdate" />
  <Login v-if="!needUpdate" />
  <Layout  />
</template>

<style scoped>

</style>
